package test2;

class outClass{
    private int a = 3;
    public static int b = 2;

    class inClass{
        private int  a = 1;
        // 在运行时确定的
        // static修饰的调用不需要实例化就能调用,而这个变量在内部类需要实例化内部类才能使用
        // public static int d = 2;
        public static final int d = 3;// 在编译的时候就确定了,是个常量,不依赖于实例化
        public int e = 2;

        public void test() {
            System.out.println("inClass::test");
            System.out.println(this.a);// 1
            System.out.println(a);// 1
            System.out.println(outClass.this.a);// 3
        }
    }

    public void test(){
        inClass inclass = new inClass();
        System.out.println(inclass.a);
        System.out.println(inclass.e);
        System.out.println("outClass::test");
    }
}

class oclass{
    private int a = 1;
    public static int b = 2;
    public int c = 3;

    static class iclass{
        public int d = 4;
        public static int e = 5;
        private int f = 6;

        public void test(){
            oclass Out = new oclass();
            System.out.println(Out.a);
            System.out.println(b);
            System.out.println(Out.c);
            System.out.println(d);
            System.out.println(e);
            System.out.println(f);

            System.out.println("iclass::test");
        }
    }

    public void test(){
        System.out.println("oclass::test");
    }
}

interface IA{
    void test();
}

public class testnbl {

    public static void main(String[] args) {
        IA a = new IA(){
            public void test(){
                System.out.println("重写了接口的方法!");
            }
        };

        a.test();

        new IA(){
            public void test(){
                System.out.println("重写了接口的方法!");
            }
        }.test();
    }

    public static void main2(String[] args) {
       oclass.iclass a = new oclass.iclass();
       a.test();
    }
    public static void main1(String[] args) {
        // 实例化内部类
        outClass class1 = new outClass();
        outClass.inClass class2 = class1.new inClass();

        class1.test();
        class2.test();
    }
}
